package com.kehutong.crm.message.admin;

import java.util.Arrays;
import java.util.Objects;
import org.coraframework.mvc.MvcAction;
import org.coraframework.mvc.http.ReqMapping;
import org.coraframework.mvc.http.result.Result;
import org.coraframework.orm.util.Enums;
import com.kehutong.common.enums.TemplateType;
import com.kehutong.common.enums.MessageBusinessEnum;
import com.kehutong.crm.message.enums.MessageConfigEnum;

/**
 * 消息管理-模板类型枚举
 */
@MvcAction
@ReqMapping("/admin/crm/message/template/enum")
public class MessageTemplateEnumController {

    @ReqMapping("/typeEnums")
    public Object typeEnums(){
        return Result.success(Arrays.asList(TemplateType.values()));
    }

    @ReqMapping("/businessEnums")
    public Object businessEnums(){
        return Result.success(Arrays.asList(MessageBusinessEnum.values()));
    }

    @ReqMapping("/templateEnums")
    public Object templateEnums(String id){
        MessageBusinessEnum businessEnum = Enums.getEnum(MessageBusinessEnum.class, id);
        if (Objects.isNull(businessEnum))
            return Result.error(0, "请选择模块类型");

        switch (businessEnum) {
            case MSG_WORK_ORDER:
                return Result.success(Arrays.asList(MessageConfigEnum.WorkOrder.values()));
            case MSG_BILL_PAY:
                return Result.success(Arrays.asList(MessageConfigEnum.Pay.values()));
            case MSG_RESIDENT:
                return Result.success(Arrays.asList(MessageConfigEnum.Resident.values()));
            case MSG_SYS_PLACARD:
                return Result.success(Arrays.asList(MessageConfigEnum.Sys.values()));
            default:
                return Result.error(0, "暂不支持该类型");
        }
    }
}
